#include <iostream>
#include <string>
#include <vector>

using namespace std;

class Solution
{
public:
    string longestCommonPrefix(vector<string> &strs)
    {
        size_t minLen;
        for(int i = 0; i < strs.size(); i++){
            minLen = min(minLen, strs[i].size());
        }
        for(int i = 0; i < minLen; i++){
            for(int j = 0; j < strs.size(); j++){
                if(strs[j][i] != strs[0][i]){
                    return strs[0].substr(0, i);
                }
            }
        }
        return strs[0].substr(0, minLen);
    }
};

int main()
{
    cout << "Code14" << endl;
    Solution s;
    vector<string> strs = {"flower", "flow", "flight"};
    cout << s.longestCommonPrefix(strs) << endl;
    return 0;
}